<template>
  <div>
    <city-header></city-header>
    <city-search></city-search>
    <!--start-->
    <city-list :cities="cities"  :hotCities="hotCities" :letter="letter"></city-list>
    <!--end-->
    <city-alphabet :cities="cities" @change="fhandLetterClick"></city-alphabet>
  </div>

</template>
<script>
import CityHeader from './components/Header'
import CitySearch from './components/Search'
import CityList from './components/List'
import CityAlphabet from './components/Alphabet'
import axios from 'axios'
export default {
  name: 'City',
  components: {
    CityHeader,
    CitySearch,
    CityList,
    CityAlphabet
  },
  data () {
    return {
      cities: {},
      hotCities: [],
      letter: ''
    }
  },
  methods: {
    getCityList () {
      let cthis = this
      axios.get('/api/city.json').then(function (res) {
        console.log(res)
        cthis.cities = res.data.data.cities
        cthis.hotCities = res.data.data.hotCities
      })
    },
    fhandLetterClick (param) {
      console.log('father')
      this.letter = param
    }
  },
  mounted () {
    this.getCityList()
  }
}
</script>
<style scoped>

</style>
